/*      */ package com.zimbra.qa.unittest.prov.soap;
/*      */ 
/*      */ import com.google.common.collect.ArrayListMultimap;
/*      */ import com.google.common.collect.Lists;
/*      */ import com.google.common.collect.Maps;
/*      */ import com.google.common.collect.Multimap;
/*      */ import com.google.common.collect.Sets;
/*      */ import com.zimbra.common.account.Key.DistributionListBy;
/*      */ import com.zimbra.common.account.ZAttrProvisioning.DistributionListSubscriptionPolicy;
/*      */ import com.zimbra.common.account.ZAttrProvisioning.DistributionListUnsubscriptionPolicy;
/*      */ import com.zimbra.common.account.ZAttrProvisioning.MailStatus;
/*      */ import com.zimbra.common.service.ServiceException;
/*      */ import com.zimbra.common.soap.SoapFaultException;
/*      */ import com.zimbra.common.soap.SoapTransport;
/*      */ import com.zimbra.cs.account.Account;
/*      */ import com.zimbra.cs.account.Domain;
/*      */ import com.zimbra.cs.account.Group;
/*      */ import com.zimbra.cs.account.Group.GroupOwner;
/*      */ import com.zimbra.cs.account.Provisioning;
/*      */ import com.zimbra.cs.account.accesscontrol.Right;
/*      */ import com.zimbra.cs.account.accesscontrol.RightCommand.ACE;
/*      */ import com.zimbra.cs.account.accesscontrol.RightCommand.Grants;
/*      */ import com.zimbra.cs.account.accesscontrol.Rights.User;
/*      */ import com.zimbra.cs.account.accesscontrol.TargetType;
/*      */ import com.zimbra.cs.account.accesscontrol.UserRight;
/*      */ import com.zimbra.qa.QA.Bug;
/*      */ import com.zimbra.qa.unittest.TestUtil;
/*      */ import com.zimbra.qa.unittest.prov.Verify;
/*      */ import com.zimbra.soap.account.message.CreateDistributionListRequest;
/*      */ import com.zimbra.soap.account.message.CreateDistributionListResponse;
/*      */ import com.zimbra.soap.account.message.DistributionListActionRequest;
/*      */ import com.zimbra.soap.account.message.DistributionListActionResponse;
/*      */ import com.zimbra.soap.account.message.GetAccountDistributionListsRequest;
/*      */ import com.zimbra.soap.account.message.GetAccountDistributionListsResponse;
/*      */ import com.zimbra.soap.account.message.GetDistributionListMembersRequest;
/*      */ import com.zimbra.soap.account.message.GetDistributionListMembersResponse;
/*      */ import com.zimbra.soap.account.message.SubscribeDistributionListRequest;
/*      */ import com.zimbra.soap.account.message.SubscribeDistributionListResponse;
/*      */ import com.zimbra.soap.account.type.DLInfo;
/*      */ import com.zimbra.soap.account.type.DistributionListAction;
/*      */ import com.zimbra.soap.account.type.DistributionListAction.Operation;
/*      */ import com.zimbra.soap.account.type.DistributionListGranteeInfo;
/*      */ import com.zimbra.soap.account.type.DistributionListGranteeSelector;
/*      */ import com.zimbra.soap.account.type.DistributionListRightInfo;
/*      */ import com.zimbra.soap.account.type.DistributionListRightSpec;
/*      */ import com.zimbra.soap.account.type.DistributionListSubscribeOp;
/*      */ import com.zimbra.soap.account.type.DistributionListSubscribeStatus;
/*      */ import com.zimbra.soap.account.type.MemberOfSelector;
/*      */ import com.zimbra.soap.admin.message.AddDistributionListAliasRequest;
/*      */ import com.zimbra.soap.admin.message.AddDistributionListAliasResponse;
/*      */ import com.zimbra.soap.admin.message.AddDistributionListMemberRequest;
/*      */ import com.zimbra.soap.admin.message.AddDistributionListMemberResponse;
/*      */ import com.zimbra.soap.admin.message.DeleteDistributionListRequest;
/*      */ import com.zimbra.soap.admin.message.DeleteDistributionListResponse;
/*      */ import com.zimbra.soap.admin.message.ModifyDistributionListRequest;
/*      */ import com.zimbra.soap.admin.message.ModifyDistributionListResponse;
/*      */ import com.zimbra.soap.admin.message.RemoveDistributionListAliasRequest;
/*      */ import com.zimbra.soap.admin.message.RemoveDistributionListAliasResponse;
/*      */ import com.zimbra.soap.admin.message.RemoveDistributionListMemberRequest;
/*      */ import com.zimbra.soap.admin.message.RemoveDistributionListMemberResponse;
/*      */ import com.zimbra.soap.admin.type.GranteeInfo;
/*      */ import com.zimbra.soap.admin.type.GranteeSelector.GranteeBy;
/*      */ import com.zimbra.soap.base.DistributionListGranteeInfoInterface;
/*      */ import com.zimbra.soap.type.DistributionListGranteeBy;
/*      */ import com.zimbra.soap.type.KeyValuePair;
/*      */ import com.zimbra.soap.type.TargetBy;
/*      */ import java.util.Collections;
/*      */ import java.util.HashMap;
/*      */ import java.util.List;
/*      */ import java.util.Map;
/*      */ import java.util.Set;
/*      */ import org.junit.AfterClass;
/*      */ import org.junit.Assert;
/*      */ import org.junit.BeforeClass;
/*      */ import org.junit.Test;
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ public class TestDelegatedDL
/*      */   extends SoapTest
/*      */ {
/*      */   private static String DOMAIN_NAME;
/*      */   private static String ADMIN;
/*      */   private static String USER_CREATOR;
/*      */   private static String USER_OWNER;
/*      */   private static String USER_NOT_OWNER;
/*      */   private static String DL_NAME;
/*      */   private static SoapProvTestUtil provUtil;
/*      */   private static Provisioning prov;
/*      */   private static Domain domain;
/*      */   private static final boolean DYNAMIC = true;
/*      */   
/*      */   @BeforeClass
/*      */   public static void init()
/*      */     throws Exception
/*      */   {
/*  119 */     DOMAIN_NAME = baseDomainName();
/*  120 */     ADMIN = TestUtil.getAddress("admin", DOMAIN_NAME);
/*  121 */     USER_CREATOR = TestUtil.getAddress("creator", DOMAIN_NAME);
/*  122 */     USER_OWNER = TestUtil.getAddress("owner", DOMAIN_NAME);
/*  123 */     USER_NOT_OWNER = TestUtil.getAddress("not-owner", DOMAIN_NAME);
/*  124 */     DL_NAME = TestUtil.getAddress("dl", DOMAIN_NAME);
/*      */     
/*  126 */     provUtil = new SoapProvTestUtil();
/*  127 */     prov = provUtil.getProv();
/*      */     
/*  129 */     domain = provUtil.createDomain(DOMAIN_NAME, new HashMap());
/*      */     
/*  131 */     Account admin = provUtil.createGlobalAdmin(ADMIN);
/*      */     
/*  133 */     Account creator = provUtil.createAccount(USER_CREATOR, new HashMap());
/*      */     
/*  135 */     Account owner = provUtil.createAccount(USER_OWNER, new HashMap());
/*      */     
/*  137 */     Account notOwner = provUtil.createAccount(USER_NOT_OWNER, new HashMap());
/*      */     
/*  139 */     prov.grantRight(TargetType.domain.getCode(), TargetBy.name, domain.getName(), com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, creator.getName(), null, Rights.User.R_createDistList.getName(), null);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  144 */     Multimap<String, String> attrs = ArrayListMultimap.create();
/*  145 */     attrs.put("zimbraDistributionListSubscriptionPolicy", ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name());
/*      */     
/*  147 */     Group group = createGroupAndAddOwner(DL_NAME, attrs, USER_OWNER);
/*      */   }
/*      */   
/*      */   @AfterClass
/*      */   public static void cleanup()
/*      */     throws Exception
/*      */   {}
/*      */   
/*      */   private static Group createDelegatedGroup(SoapTransport transport, String groupName, List<KeyValuePair> attrs)
/*      */     throws Exception
/*      */   {
/*  158 */     Group group = prov.getGroup(Key.DistributionListBy.name, groupName);
/*  159 */     Assert.assertNull(group);
/*      */     
/*  161 */     CreateDistributionListRequest req = new CreateDistributionListRequest(groupName, attrs, Boolean.valueOf(true));
/*      */     
/*  163 */     CreateDistributionListResponse resp = (CreateDistributionListResponse)invokeJaxb(transport, req);
/*      */     
/*  165 */     group = prov.getGroup(Key.DistributionListBy.name, groupName);
/*  166 */     Assert.assertNotNull(group);
/*  167 */     Assert.assertEquals(groupName, group.getName());
/*  168 */     Assert.assertNotNull(group.getAttr("zimbraMailHost"));
/*      */     
/*  170 */     return group;
/*      */   }
/*      */   
/*      */   private static Group createGroupAndAddOwner(String groupName) throws Exception {
/*  174 */     return createGroupAndAddOwner(groupName, null, USER_OWNER);
/*      */   }
/*      */   
/*      */   private static Group createGroupAndAddOwner(String groupName, String ownerName) throws Exception
/*      */   {
/*  179 */     return createGroupAndAddOwner(groupName, null, ownerName);
/*      */   }
/*      */   
/*      */   private static Group createGroupAndAddOwner(String groupName, Multimap<String, String> attrs, String ownerName)
/*      */     throws Exception
/*      */   {
/*  185 */     Group group = prov.getGroup(Key.DistributionListBy.name, groupName);
/*  186 */     Assert.assertNull(group);
/*      */     
/*  188 */     SoapTransport transport = authUser(USER_CREATOR);
/*      */     
/*  190 */     CreateDistributionListRequest req = new CreateDistributionListRequest(groupName, KeyValuePair.fromMultimap(attrs), Boolean.valueOf(true));
/*      */     
/*  192 */     CreateDistributionListResponse resp = (CreateDistributionListResponse)invokeJaxb(transport, req);
/*      */     
/*  194 */     group = prov.getGroup(Key.DistributionListBy.name, groupName);
/*  195 */     Assert.assertNotNull(group);
/*  196 */     Assert.assertEquals(groupName, group.getName());
/*  197 */     Assert.assertNotNull(group.getAttr("zimbraMailHost"));
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  204 */     addOwner(transport, groupName, ownerName);
/*      */     
/*      */ 
/*  207 */     removeOwner(transport, groupName, USER_CREATOR);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  228 */     return group;
/*      */   }
/*      */   
/*      */   private static void addOwner(SoapTransport transport, String groupName, String ownerName) throws Exception
/*      */   {
/*  233 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.addOwners);
/*  234 */     DistributionListActionRequest actionReq = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(groupName), action);
/*      */     
/*      */ 
/*  237 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, ownerName));
/*      */     
/*  239 */     DistributionListActionResponse actionResp = (DistributionListActionResponse)invokeJaxb(transport, actionReq);
/*      */   }
/*      */   
/*      */   private static void removeOwner(SoapTransport transport, String groupName, String ownerName) throws Exception
/*      */   {
/*  244 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.removeOwners);
/*  245 */     DistributionListActionRequest actionReq = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(groupName), action);
/*      */     
/*      */ 
/*  248 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, ownerName));
/*      */     
/*  250 */     DistributionListActionResponse actionResp = (DistributionListActionResponse)invokeJaxb(transport, actionReq);
/*      */   }
/*      */   
/*      */   private String getAddress(String localpart) {
/*  254 */     return TestUtil.getAddress(localpart, DOMAIN_NAME);
/*      */   }
/*      */   
/*      */   private void verifyCaughtProxyError(SoapTransport transport, Object jaxbObject) throws Exception
/*      */   {
/*  259 */     boolean caughtProxyError = false;
/*      */     try {
/*  261 */       invokeJaxb(transport, jaxbObject);
/*      */     } catch (ServiceException e) {
/*  263 */       if ("service.PROXY_ERROR".equals(e.getCode())) {
/*  264 */         caughtProxyError = true;
/*      */       }
/*      */     }
/*  267 */     Assert.assertTrue(caughtProxyError);
/*      */   }
/*      */   
/*      */ 
/*      */   @Test
/*      */   public void getDistributionListAdmin()
/*      */     throws Exception
/*      */   {
/*  275 */     SoapTransport transport = authAdmin(ADMIN);
/*      */     
/*  277 */     com.zimbra.soap.admin.message.GetDistributionListRequest req = new com.zimbra.soap.admin.message.GetDistributionListRequest(com.zimbra.soap.admin.type.DistributionListSelector.fromName(DL_NAME));
/*      */     
/*      */ 
/*      */ 
/*  281 */     com.zimbra.soap.admin.message.GetDistributionListResponse resp = (com.zimbra.soap.admin.message.GetDistributionListResponse)invokeJaxb(transport, req);
/*  282 */     com.zimbra.soap.admin.type.DistributionListInfo dlInfo = resp.getDl();
/*      */     
/*  284 */     String dlId = dlInfo.getId();
/*      */     
/*  286 */     Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
/*  287 */     Assert.assertNotNull(group);
/*  288 */     Assert.assertEquals(group.getId(), dlId);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  298 */     List<GranteeInfo> dlOwners = dlInfo.getOwners();
/*  299 */     Assert.assertEquals(1L, dlOwners.size());
/*  300 */     for (GranteeInfo owner : dlOwners) {
/*  301 */       com.zimbra.soap.type.GranteeType type = owner.getType();
/*  302 */       String id = owner.getId();
/*  303 */       String name = owner.getName();
/*      */       
/*  305 */       Assert.assertEquals(com.zimbra.soap.type.GranteeType.usr, type);
/*  306 */       Assert.assertEquals(USER_OWNER, name);
/*      */     }
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void createDistributionListPermDenied() throws Exception {
/*  312 */     String dlName = getAddress(genGroupNameLocalPart());
/*  313 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*  315 */     CreateDistributionListRequest req = new CreateDistributionListRequest(dlName, null, Boolean.valueOf(true));
/*      */     
/*      */ 
/*  318 */     boolean caughtPermDenied = false;
/*      */     try {
/*  320 */       resp = (CreateDistributionListResponse)invokeJaxb(transport, req);
/*      */     } catch (SoapFaultException e) { CreateDistributionListResponse resp;
/*  322 */       String code = e.getCode();
/*  323 */       if ("service.PERM_DENIED".equals(code)) {
/*  324 */         caughtPermDenied = true;
/*      */       }
/*      */     }
/*      */     
/*  328 */     Assert.assertTrue(caughtPermDenied);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */   @Test
/*      */   public void ownDistListRightTarget()
/*      */     throws Exception
/*      */   {
/*  337 */     Group group = provUtil.createGroup(genGroupNameLocalPart("group"), domain, true);
/*  338 */     Account acct = provUtil.createAccount(genAcctNameLocalPart("acct"), domain);
/*      */     
/*  340 */     String right = Group.GroupOwner.GROUP_OWNER_RIGHT.getName();
/*      */     
/*      */ 
/*  343 */     prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group.getName(), com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, acct.getName(), null, right, null);
/*      */     
/*      */ 
/*  346 */     prov.checkRight(TargetType.dl.getCode(), TargetBy.name, group.getName(), GranteeSelector.GranteeBy.name, acct.getName(), right, null, null);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  351 */     boolean cauchtException = false;
/*      */     try {
/*  353 */       prov.grantRight(TargetType.domain.getCode(), TargetBy.name, domain.getName(), com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, acct.getName(), null, right, null);
/*      */     }
/*      */     catch (ServiceException e)
/*      */     {
/*  357 */       if ("service.INVALID_REQUEST".equals(e.getCode())) {
/*  358 */         cauchtException = true;
/*      */       }
/*      */     }
/*  361 */     Assert.assertTrue(cauchtException);
/*      */     
/*      */ 
/*      */ 
/*  365 */     cauchtException = false;
/*      */     try {
/*  367 */       prov.grantRight(TargetType.global.getCode(), null, null, com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, acct.getName(), null, right, null);
/*      */     }
/*      */     catch (ServiceException e)
/*      */     {
/*  371 */       if ("service.INVALID_REQUEST".equals(e.getCode())) {
/*  372 */         cauchtException = true;
/*      */       }
/*      */     }
/*  375 */     Assert.assertTrue(cauchtException);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void createDistributionList() throws Exception {
/*  380 */     String dlName = getAddress(genGroupNameLocalPart());
/*      */     
/*  382 */     SoapTransport transport = authUser(USER_CREATOR);
/*      */     
/*  384 */     CreateDistributionListRequest req = new CreateDistributionListRequest(dlName, null, Boolean.valueOf(true));
/*      */     
/*      */ 
/*  387 */     List<KeyValuePair> attrsCreate = Lists.newArrayList(new KeyValuePair[] { new KeyValuePair("zimbraDistributionListSubscriptionPolicy", ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name()) });
/*      */     
/*      */ 
/*      */ 
/*  391 */     req.setKeyValuePairs(attrsCreate);
/*  392 */     CreateDistributionListResponse resp = (CreateDistributionListResponse)invokeJaxb(transport, req);
/*  393 */     DLInfo dlInfo = resp.getDl();
/*      */     
/*  395 */     String dlId = dlInfo.getId();
/*      */     
/*  397 */     Group group = prov.getGroup(Key.DistributionListBy.name, dlName);
/*  398 */     Assert.assertNotNull(group);
/*  399 */     Assert.assertEquals(group.getId(), dlId);
/*      */     
/*  401 */     boolean seenExpectedMail = false;
/*  402 */     boolean seenExpectedSubsPolicy = false;
/*  403 */     List<? extends KeyValuePair> attrs = dlInfo.getAttrList();
/*  404 */     for (KeyValuePair attr : attrs) {
/*  405 */       String name = attr.getKey();
/*  406 */       String value = attr.getValue();
/*  407 */       if ("mail".equals(name)) {
/*  408 */         Assert.assertEquals(group.getName(), value);
/*  409 */         seenExpectedMail = true;
/*      */       }
/*      */       
/*  412 */       if ("zimbraDistributionListSubscriptionPolicy".equals(name)) {
/*  413 */         Assert.assertEquals(ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name(), value);
/*  414 */         seenExpectedSubsPolicy = true;
/*      */       }
/*      */     }
/*  417 */     Assert.assertTrue(seenExpectedMail);
/*  418 */     Assert.assertTrue(seenExpectedSubsPolicy);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void getDistributionList() throws Exception {
/*  423 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*  425 */     com.zimbra.soap.account.message.GetDistributionListRequest req = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(DL_NAME), Boolean.TRUE);
/*      */     
/*      */ 
/*  428 */     com.zimbra.soap.account.message.GetDistributionListResponse resp = (com.zimbra.soap.account.message.GetDistributionListResponse)invokeJaxb(transport, req);
/*      */     
/*  430 */     com.zimbra.soap.account.type.DistributionListInfo dlInfo = resp.getDl();
/*      */     
/*  432 */     Assert.assertTrue(dlInfo.isOwner().booleanValue());
/*  433 */     Assert.assertFalse(dlInfo.isMember().booleanValue());
/*      */     
/*  435 */     String dlId = dlInfo.getId();
/*      */     
/*  437 */     Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
/*  438 */     Assert.assertNotNull(group);
/*  439 */     Assert.assertEquals(group.getId(), dlId);
/*      */     
/*  441 */     boolean seenMail = false;
/*  442 */     boolean seenSubsPolicy = false;
/*  443 */     boolean seenUnsubsPolicy = false;
/*  444 */     List<? extends KeyValuePair> attrs = dlInfo.getAttrList();
/*  445 */     for (KeyValuePair attr : attrs) {
/*  446 */       String name = attr.getKey();
/*  447 */       String value = attr.getValue();
/*  448 */       if ("mail".equals(name)) {
/*  449 */         Assert.assertEquals(group.getName(), value);
/*  450 */         seenMail = true;
/*      */       }
/*  452 */       if ("zimbraDistributionListSubscriptionPolicy".equals(name)) {
/*  453 */         Assert.assertEquals(ZAttrProvisioning.DistributionListSubscriptionPolicy.ACCEPT.name(), value);
/*  454 */         seenSubsPolicy = true;
/*      */       }
/*      */       
/*      */ 
/*      */ 
/*  459 */       if ("zimbraDistributionListUnsubscriptionPolicy".equals(name)) {
/*  460 */         Assert.assertEquals(ZAttrProvisioning.DistributionListUnsubscriptionPolicy.REJECT.name(), value);
/*  461 */         seenUnsubsPolicy = true;
/*      */       }
/*      */     }
/*      */     
/*  465 */     Assert.assertTrue(seenMail);
/*  466 */     Assert.assertTrue(seenSubsPolicy);
/*  467 */     Assert.assertTrue(seenUnsubsPolicy);
/*      */     
/*  469 */     List<? extends DistributionListGranteeInfoInterface> dlOwners = dlInfo.getOwners();
/*  470 */     Assert.assertEquals(1L, dlOwners.size());
/*  471 */     for (DistributionListGranteeInfoInterface owner : dlOwners) {
/*  472 */       com.zimbra.soap.type.GranteeType type = owner.getType();
/*  473 */       String id = owner.getId();
/*  474 */       String name = owner.getName();
/*      */       
/*  476 */       Assert.assertEquals(com.zimbra.soap.type.GranteeType.usr, type);
/*  477 */       Assert.assertEquals(USER_OWNER, name);
/*      */     }
/*      */   }
/*      */   
/*      */ 
/*      */   @Test
/*      */   public void getDistributionListByGlobalAdmin()
/*      */     throws Exception
/*      */   {
/*  486 */     SoapTransport transport = authAdmin(ADMIN);
/*      */     
/*  488 */     com.zimbra.soap.account.message.GetDistributionListRequest req = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(DL_NAME), Boolean.TRUE);
/*      */     
/*      */ 
/*  491 */     com.zimbra.soap.account.message.GetDistributionListResponse resp = (com.zimbra.soap.account.message.GetDistributionListResponse)invokeJaxb(transport, req);
/*      */     
/*  493 */     com.zimbra.soap.account.type.DistributionListInfo dlInfo = resp.getDl();
/*  494 */     Assert.assertFalse(dlInfo.isOwner().booleanValue());
/*      */     
/*  496 */     String dlId = dlInfo.getId();
/*      */     
/*  498 */     Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
/*  499 */     Assert.assertNotNull(group);
/*  500 */     Assert.assertEquals(group.getId(), dlId);
/*      */   }
/*      */   
/*      */ 
/*      */   @Test
/*      */   public void getDistributionListRights()
/*      */     throws Exception
/*      */   {
/*  508 */     String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
/*  509 */     Group group = createGroupAndAddOwner(GROUP_NAME);
/*      */     
/*  511 */     String right1 = "sendToDistList";
/*  512 */     String right2 = "viewDistList";
/*  513 */     Account grantee1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
/*  514 */     Account grantee2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
/*      */     
/*  516 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  521 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.grantRights);
/*  522 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/*  525 */     DistributionListRightSpec dlRight1 = new DistributionListRightSpec(right1);
/*  526 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee1.getName()));
/*      */     
/*  528 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee2.getName()));
/*      */     
/*      */ 
/*  531 */     DistributionListRightSpec dlRight2 = new DistributionListRightSpec(right2);
/*  532 */     dlRight2.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.all, null, null));
/*      */     
/*      */ 
/*  535 */     action.addRight(dlRight1);
/*  536 */     action.addRight(dlRight2);
/*  537 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  542 */     com.zimbra.soap.account.message.GetDistributionListRequest getDLReq = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), Boolean.FALSE, right1 + "," + right2);
/*      */     
/*      */ 
/*  545 */     com.zimbra.soap.account.message.GetDistributionListResponse getDLResp = (com.zimbra.soap.account.message.GetDistributionListResponse)invokeJaxb(transport, getDLReq);
/*      */     
/*  547 */     com.zimbra.soap.account.type.DistributionListInfo dlInfo = getDLResp.getDl();
/*  548 */     List<? extends DistributionListRightInfo> rights = dlInfo.getRights();
/*      */     
/*  550 */     Set<String> right1GranteeNames = Sets.newHashSet();
/*  551 */     Set<String> right2GranteeNames = Sets.newHashSet();
/*  552 */     for (DistributionListRightInfo rightInfo : rights) {
/*  553 */       String right = rightInfo.getRight();
/*  554 */       List<DistributionListGranteeInfo> grantees = rightInfo.getGrantees();
/*      */       
/*  556 */       if (right1.equals(right)) {
/*  557 */         for (DistributionListGranteeInfo grantee : grantees) {
/*  558 */           right1GranteeNames.add(Verify.makeResultStr(new Object[] { grantee.getType().name(), grantee.getName() }));
/*      */         }
/*  560 */       } else if (right2.equals(right)) {
/*  561 */         for (DistributionListGranteeInfo grantee : grantees) {
/*  562 */           right2GranteeNames.add(Verify.makeResultStr(new Object[] { grantee.getType().name(), grantee.getName() }));
/*      */         }
/*      */       }
/*      */     }
/*      */     
/*  567 */     Verify.verifyEquals(Sets.newHashSet(new String[] { Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee1.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee2.getName() }) }), right1GranteeNames);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  572 */     Verify.verifyEquals(Sets.newHashSet(new String[] { Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_AUTHUSER.getCode(), "null" }) }), right2GranteeNames);
/*      */   }
/*      */   
/*      */ 
/*      */   @Test
/*      */   public void distributionListActionAddRemoveMembers()
/*      */     throws Exception
/*      */   {
/*  580 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*      */ 
/*  583 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.addMembers);
/*  584 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(DL_NAME), action);
/*      */     
/*      */ 
/*  587 */     Account member1 = provUtil.createAccount(genAcctNameLocalPart("member1"), domain);
/*  588 */     Account member2 = provUtil.createAccount(genAcctNameLocalPart("member2"), domain);
/*  589 */     String MEMBER1 = member1.getName();
/*  590 */     String MEMBER2 = member2.getName();
/*      */     
/*  592 */     action.addMember(MEMBER1);
/*  593 */     action.addMember(MEMBER2);
/*  594 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*  596 */     Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
/*  597 */     Set<String> members = group.getAllMembersSet();
/*      */     
/*  599 */     Verify.verifyEquals(Sets.newHashSet(new String[] { MEMBER1, MEMBER2 }), members);
/*      */     
/*      */ 
/*  602 */     action = new DistributionListAction(DistributionListAction.Operation.removeMembers);
/*  603 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(DL_NAME), action);
/*      */     
/*  605 */     action.addMember(MEMBER1);
/*  606 */     action.addMember(MEMBER2);
/*  607 */     resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*  609 */     group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
/*  610 */     members = group.getAllMembersSet();
/*  611 */     Assert.assertEquals(0L, members.size());
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListActionAddRemoveOwners() throws Exception {
/*  616 */     String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
/*  617 */     Group group = createGroupAndAddOwner(GROUP_NAME);
/*      */     
/*  619 */     Account owner1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
/*  620 */     Account owner2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
/*      */     
/*  622 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  627 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.addOwners);
/*  628 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/*  631 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, USER_OWNER));
/*      */     
/*  633 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner1.getName()));
/*      */     
/*  635 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner2.getName()));
/*      */     
/*  637 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  642 */     com.zimbra.soap.account.message.GetDistributionListRequest getDLReq = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
/*      */     
/*  644 */     com.zimbra.soap.account.message.GetDistributionListResponse getDLResp = (com.zimbra.soap.account.message.GetDistributionListResponse)invokeJaxb(transport, getDLReq);
/*  645 */     com.zimbra.soap.account.type.DistributionListInfo dlInfo = getDLResp.getDl();
/*  646 */     List<? extends DistributionListGranteeInfoInterface> owners = dlInfo.getOwners();
/*  647 */     Set<String> ownerNames = Sets.newHashSet();
/*  648 */     for (DistributionListGranteeInfoInterface owner : owners) {
/*  649 */       if (owner.getType() == com.zimbra.soap.type.GranteeType.usr) {
/*  650 */         ownerNames.add(owner.getName());
/*      */       }
/*      */     }
/*  653 */     Assert.assertEquals(3L, owners.size());
/*  654 */     Verify.verifyEquals(Sets.newHashSet(new String[] { USER_OWNER, owner1.getName(), owner2.getName() }), ownerNames);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  662 */     action = new DistributionListAction(DistributionListAction.Operation.removeOwners);
/*  663 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*  665 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner1.getName()));
/*      */     
/*  667 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner2.getName()));
/*      */     
/*  669 */     resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  674 */     getDLReq = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
/*      */     
/*  676 */     getDLResp = (com.zimbra.soap.account.message.GetDistributionListResponse)invokeJaxb(transport, getDLReq);
/*  677 */     dlInfo = getDLResp.getDl();
/*  678 */     owners = dlInfo.getOwners();
/*  679 */     ownerNames = Sets.newHashSet();
/*  680 */     for (DistributionListGranteeInfoInterface owner : owners) {
/*  681 */       if (owner.getType() == com.zimbra.soap.type.GranteeType.usr) {
/*  682 */         ownerNames.add(owner.getName());
/*      */       }
/*      */     }
/*  685 */     Assert.assertEquals(1L, owners.size());
/*  686 */     Verify.verifyEquals(Sets.newHashSet(new String[] { USER_OWNER }), ownerNames);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListActionSetOwners() throws Exception {
/*  691 */     String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
/*  692 */     Group group = createGroupAndAddOwner(GROUP_NAME);
/*      */     
/*  694 */     Account owner1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
/*  695 */     Account owner2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
/*  696 */     Account owner3 = provUtil.createAccount(genAcctNameLocalPart("3"), domain);
/*      */     
/*  698 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  703 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.setOwners);
/*  704 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/*  707 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, USER_OWNER));
/*      */     
/*  709 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner1.getName()));
/*      */     
/*  711 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner2.getName()));
/*      */     
/*  713 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, owner3.getName()));
/*      */     
/*  715 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  720 */     com.zimbra.soap.account.message.GetDistributionListRequest getDLReq = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
/*      */     
/*  722 */     com.zimbra.soap.account.message.GetDistributionListResponse getDLResp = (com.zimbra.soap.account.message.GetDistributionListResponse)invokeJaxb(transport, getDLReq);
/*  723 */     com.zimbra.soap.account.type.DistributionListInfo dlInfo = getDLResp.getDl();
/*  724 */     List<? extends DistributionListGranteeInfoInterface> owners = dlInfo.getOwners();
/*  725 */     Set<String> ownerNames = Sets.newHashSet();
/*  726 */     for (DistributionListGranteeInfoInterface owner : owners) {
/*  727 */       if (owner.getType() == com.zimbra.soap.type.GranteeType.usr) {
/*  728 */         ownerNames.add(owner.getName());
/*      */       }
/*      */     }
/*  731 */     Assert.assertEquals(4L, owners.size());
/*  732 */     Verify.verifyEquals(Sets.newHashSet(new String[] { USER_OWNER, owner1.getName(), owner2.getName(), owner3.getName() }), ownerNames);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  740 */     action = new DistributionListAction(DistributionListAction.Operation.setOwners);
/*  741 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/*  744 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, "user@external.com"));
/*      */     
/*      */ 
/*  747 */     String errCode = null;
/*      */     try {
/*  749 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/*  751 */       errCode = e.getCode();
/*      */     }
/*  753 */     Assert.assertEquals("service.INVALID_REQUEST", errCode);
/*      */     
/*      */ 
/*      */ 
/*  757 */     action = new DistributionListAction(DistributionListAction.Operation.setOwners);
/*  758 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*  760 */     resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*  762 */     getDLReq = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
/*      */     
/*  764 */     getDLResp = (com.zimbra.soap.account.message.GetDistributionListResponse)invokeJaxb(transport, getDLReq);
/*  765 */     dlInfo = getDLResp.getDl();
/*  766 */     owners = dlInfo.getOwners();
/*  767 */     Assert.assertEquals(0L, owners.size());
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListActionGrantRevokeSetRights() throws Exception
/*      */   {
/*  773 */     String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
/*  774 */     Group group = createGroupAndAddOwner(GROUP_NAME);
/*      */     
/*  776 */     String right1 = "sendToDistList";
/*  777 */     String right2 = "viewDistList";
/*  778 */     Account grantee1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
/*  779 */     Account grantee2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
/*  780 */     Group groupGrantee1 = provUtil.createGroup(genGroupNameLocalPart("3"), domain, true);
/*      */     
/*      */ 
/*  783 */     Account grantee3 = provUtil.createAccount(genAcctNameLocalPart("4"), domain);
/*  784 */     Account grantee4 = provUtil.createAccount(genAcctNameLocalPart("5"), domain);
/*  785 */     Group groupGrantee2 = provUtil.createGroup(genGroupNameLocalPart("6"), domain, true);
/*  786 */     String GUEST = "user@external.com";
/*      */     
/*  788 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  793 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.grantRights);
/*  794 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/*  797 */     DistributionListRightSpec dlRight1 = new DistributionListRightSpec(right1);
/*  798 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee1.getName()));
/*      */     
/*  800 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee2.getName()));
/*      */     
/*  802 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.grp, DistributionListGranteeBy.name, groupGrantee1.getName()));
/*      */     
/*  804 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.all, null, null));
/*      */     
/*  806 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.pub, null, null));
/*      */     
/*  808 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee3.getName()));
/*      */     
/*  810 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee4.getName()));
/*      */     
/*  812 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, groupGrantee2.getName()));
/*      */     
/*  814 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, GUEST));
/*      */     
/*      */ 
/*  817 */     DistributionListRightSpec dlRight2 = new DistributionListRightSpec(right2);
/*  818 */     dlRight2.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee1.getName()));
/*      */     
/*  820 */     dlRight2.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee2.getName()));
/*      */     
/*      */ 
/*  823 */     action.addRight(dlRight1);
/*  824 */     action.addRight(dlRight2);
/*  825 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  830 */     RightCommand.Grants grants = prov.getGrants(TargetType.dl.name(), TargetBy.id, group.getId(), null, null, null, true);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  835 */     Set<String> right1GranteeNames = Sets.newHashSet();
/*  836 */     Set<String> right2GranteeNames = Sets.newHashSet();
/*  837 */     for (RightCommand.ACE ace : grants.getACEs()) {
/*  838 */       String right = ace.right();
/*  839 */       if (right1.equals(right)) {
/*  840 */         right1GranteeNames.add(Verify.makeResultStr(new Object[] { ace.granteeType(), ace.granteeName() }));
/*  841 */       } else if (right2.equals(right)) {
/*  842 */         right2GranteeNames.add(Verify.makeResultStr(new Object[] { ace.granteeType(), ace.granteeName() }));
/*      */       }
/*      */     }
/*  845 */     Verify.verifyEquals(Sets.newHashSet(new String[] { Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee1.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee2.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_GROUP.getCode(), groupGrantee1.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_AUTHUSER.getCode(), "" }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_PUBLIC.getCode(), "" }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee3.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee4.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_GROUP.getCode(), groupGrantee2.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_GUEST.getCode(), GUEST }) }), right1GranteeNames);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  857 */     Verify.verifyEquals(Sets.newHashSet(new String[] { Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee1.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee2.getName() }) }), right2GranteeNames);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  867 */     action = new DistributionListAction(DistributionListAction.Operation.setRights);
/*  868 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*  870 */     dlRight1 = new DistributionListRightSpec(right1);
/*  871 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.all, null, null));
/*      */     
/*  873 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee3.getName()));
/*      */     
/*  875 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee4.getName()));
/*      */     
/*  877 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, groupGrantee2.getName()));
/*      */     
/*  879 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, GUEST));
/*      */     
/*      */ 
/*  882 */     dlRight2 = new DistributionListRightSpec(right2);
/*      */     
/*      */ 
/*  885 */     action.addRight(dlRight1);
/*  886 */     action.addRight(dlRight2);
/*  887 */     resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  892 */     grants = prov.getGrants(TargetType.dl.name(), TargetBy.id, group.getId(), null, null, null, true);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  897 */     right1GranteeNames = Sets.newHashSet();
/*  898 */     right2GranteeNames = Sets.newHashSet();
/*  899 */     for (RightCommand.ACE ace : grants.getACEs()) {
/*  900 */       String right = ace.right();
/*  901 */       if (right1.equals(right)) {
/*  902 */         right1GranteeNames.add(Verify.makeResultStr(new Object[] { ace.granteeType(), ace.granteeName() }));
/*  903 */       } else if (right2.equals(right)) {
/*  904 */         right2GranteeNames.add(Verify.makeResultStr(new Object[] { ace.granteeType(), ace.granteeName() }));
/*      */       }
/*      */     }
/*  907 */     Verify.verifyEquals(Sets.newHashSet(new String[] { Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_AUTHUSER.getCode(), "" }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee3.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), grantee4.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_GROUP.getCode(), groupGrantee2.getName() }), Verify.makeResultStr(new Object[] { com.zimbra.cs.account.accesscontrol.GranteeType.GT_GUEST.getCode(), GUEST }) }), right1GranteeNames);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  915 */     Assert.assertEquals(0L, right2GranteeNames.size());
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*  921 */     action = new DistributionListAction(DistributionListAction.Operation.revokeRights);
/*  922 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*  924 */     dlRight1 = new DistributionListRightSpec(right1);
/*  925 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.all, null, null));
/*      */     
/*  927 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee3.getName()));
/*      */     
/*  929 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, grantee4.getName()));
/*      */     
/*  931 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, groupGrantee2.getName()));
/*      */     
/*  933 */     dlRight1.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.email, DistributionListGranteeBy.name, GUEST));
/*      */     
/*      */ 
/*  936 */     action.addRight(dlRight1);
/*  937 */     resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  942 */     grants = prov.getGrants(TargetType.dl.name(), TargetBy.id, group.getId(), null, null, null, true);
/*      */     
/*      */ 
/*      */ 
/*  946 */     right1GranteeNames = Sets.newHashSet();
/*  947 */     right2GranteeNames = Sets.newHashSet();
/*  948 */     for (RightCommand.ACE ace : grants.getACEs()) {
/*  949 */       String right = ace.right();
/*  950 */       if (right1.equals(right)) {
/*  951 */         right1GranteeNames.add(ace.granteeName());
/*  952 */       } else if (right2.equals(right)) {
/*  953 */         right2GranteeNames.add(ace.granteeName());
/*      */       }
/*      */     }
/*  956 */     Assert.assertEquals(0L, right1GranteeNames.size());
/*  957 */     Assert.assertEquals(0L, right2GranteeNames.size());
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */   @Test
/*      */   public void distributionListActionManipulateOwnerRight()
/*      */     throws Exception
/*      */   {
/*  966 */     String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
/*  967 */     Group group = createGroupAndAddOwner(GROUP_NAME);
/*      */     
/*  969 */     String right = Group.GroupOwner.GROUP_OWNER_RIGHT.getName();
/*  970 */     Account grantee = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
/*      */     
/*  972 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*  977 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.grantRights);
/*  978 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/*  981 */     DistributionListRightSpec dlRight = new DistributionListRightSpec(right);
/*  982 */     dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
/*      */     
/*      */ 
/*  985 */     action.addRight(dlRight);
/*      */     
/*      */ 
/*  988 */     boolean caughtException = false;
/*      */     DistributionListActionResponse resp;
/*  990 */     try { resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/*  992 */       if ("service.INVALID_REQUEST".equals(e.getCode())) {
/*  993 */         caughtException = true;
/*      */       }
/*      */     }
/*  996 */     Assert.assertTrue(caughtException);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1002 */     action = new DistributionListAction(DistributionListAction.Operation.revokeRights);
/* 1003 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/* 1006 */     dlRight = new DistributionListRightSpec(right);
/* 1007 */     dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
/*      */     
/*      */ 
/* 1010 */     action.addRight(dlRight);
/*      */     
/* 1012 */     caughtException = false;
/*      */     try {
/* 1014 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1016 */       if ("service.INVALID_REQUEST".equals(e.getCode())) {
/* 1017 */         caughtException = true;
/*      */       }
/*      */     }
/* 1020 */     Assert.assertTrue(caughtException);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1026 */     action = new DistributionListAction(DistributionListAction.Operation.setRights);
/* 1027 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/* 1030 */     dlRight = new DistributionListRightSpec(right);
/* 1031 */     dlRight.addGrantee(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, grantee.getName()));
/*      */     
/*      */ 
/* 1034 */     action.addRight(dlRight);
/*      */     
/* 1036 */     caughtException = false;
/*      */     try {
/* 1038 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1040 */       if ("service.INVALID_REQUEST".equals(e.getCode())) {
/* 1041 */         caughtException = true;
/*      */       }
/*      */     }
/* 1044 */     Assert.assertTrue(caughtException);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListActionModify() throws Exception
/*      */   {
/* 1050 */     String ATTR = "description";
/* 1051 */     String VALUE = "test description";
/*      */     
/* 1053 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/* 1055 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.modify);
/*      */     
/* 1057 */     List<KeyValuePair> attrs = Lists.newArrayList(new KeyValuePair[] { new KeyValuePair(ATTR, VALUE) });
/* 1058 */     action.setKeyValuePairs(attrs);
/*      */     
/* 1060 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(DL_NAME), action);
/*      */     
/*      */ 
/* 1063 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/* 1064 */     Group group = prov.getGroup(Key.DistributionListBy.name, DL_NAME);
/* 1065 */     Assert.assertEquals(VALUE, group.getAttr(ATTR));
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListActionRename() throws Exception {
/* 1070 */     String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
/*      */     
/*      */ 
/* 1073 */     Account ownerAcct = provUtil.createAccount(genAcctNameLocalPart("owner"), domain);
/* 1074 */     Group group = createGroupAndAddOwner(GROUP_NAME, ownerAcct.getName());
/*      */     
/*      */ 
/* 1077 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.rename);
/* 1078 */     String GROUP_NEW_NAME = getAddress(genGroupNameLocalPart("new-name"));
/* 1079 */     action.setNewName(GROUP_NEW_NAME);
/*      */     
/* 1081 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1086 */     SoapTransport transport = authUser(ownerAcct.getName());
/* 1087 */     String errorCode = null;
/*      */     try
/*      */     {
/* 1090 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1092 */       errorCode = e.getCode();
/*      */     }
/* 1094 */     Assert.assertEquals("service.PERM_DENIED", errorCode);
/*      */     
/*      */ 
/* 1097 */     transport = authUser(USER_CREATOR);
/* 1098 */     errorCode = null;
/*      */     try {
/* 1100 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1102 */       errorCode = e.getCode();
/*      */     }
/* 1104 */     Assert.assertEquals("service.PERM_DENIED", errorCode);
/*      */     
/*      */ 
/* 1107 */     transport = authUser(ownerAcct.getName());
/* 1108 */     addOwner(transport, GROUP_NAME, USER_CREATOR);
/*      */     
/*      */ 
/* 1111 */     transport = authUser(USER_CREATOR);
/* 1112 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/* 1114 */     group = prov.getGroup(Key.DistributionListBy.name, GROUP_NEW_NAME);
/* 1115 */     Assert.assertEquals(GROUP_NEW_NAME, group.getName());
/*      */     
/*      */ 
/* 1118 */     Domain otherDomain = provUtil.createDomain(genDomainName(domain.getName()));
/* 1119 */     String GROUP_NEW_NAME_IN_ANOTHER_DOMAIN = TestUtil.getAddress(genGroupNameLocalPart(), otherDomain.getName());
/*      */     
/*      */ 
/* 1122 */     action = new DistributionListAction(DistributionListAction.Operation.rename);
/* 1123 */     action.setNewName(GROUP_NEW_NAME_IN_ANOTHER_DOMAIN);
/* 1124 */     req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(group.getName()), action);
/*      */     
/*      */ 
/* 1127 */     transport = authUser(USER_CREATOR);
/* 1128 */     errorCode = null;
/*      */     try
/*      */     {
/* 1131 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1133 */       errorCode = e.getCode();
/*      */     }
/* 1135 */     Assert.assertEquals("service.PERM_DENIED", errorCode);
/*      */     
/* 1137 */     transport = authUser(ownerAcct.getName());
/* 1138 */     errorCode = null;
/*      */     try
/*      */     {
/* 1141 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1143 */       errorCode = e.getCode();
/*      */     }
/* 1145 */     Assert.assertEquals("service.PERM_DENIED", errorCode);
/*      */     
/*      */ 
/* 1148 */     prov.grantRight(TargetType.domain.getCode(), TargetBy.name, otherDomain.getName(), com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, USER_CREATOR, null, Rights.User.R_createDistList.getName(), null);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1153 */     transport = authUser(USER_CREATOR);
/* 1154 */     resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/* 1156 */     group = prov.getGroup(Key.DistributionListBy.name, GROUP_NEW_NAME_IN_ANOTHER_DOMAIN);
/* 1157 */     Assert.assertEquals(GROUP_NEW_NAME_IN_ANOTHER_DOMAIN, group.getName());
/*      */     
/* 1159 */     provUtil.deleteAccount(ownerAcct);
/* 1160 */     provUtil.deleteGroup(group);
/* 1161 */     provUtil.deleteDomain(otherDomain);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void distributionListActionDelete() throws Exception
/*      */   {
/* 1167 */     String NAME = getAddress(genGroupNameLocalPart());
/* 1168 */     Group group = createGroupAndAddOwner(NAME);
/*      */     
/* 1170 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/* 1172 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.delete);
/* 1173 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(NAME), action);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1178 */     String errorCode = null;
/*      */     try
/*      */     {
/* 1181 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1183 */       errorCode = e.getCode();
/*      */     }
/* 1185 */     Assert.assertEquals("service.PERM_DENIED", errorCode);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1190 */     transport = authUser(USER_CREATOR);
/* 1191 */     errorCode = null;
/*      */     try {
/* 1193 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1195 */       errorCode = e.getCode();
/*      */     }
/* 1197 */     Assert.assertEquals("service.PERM_DENIED", errorCode);
/*      */     
/*      */ 
/* 1200 */     transport = authUser(USER_OWNER);
/* 1201 */     addOwner(transport, group.getName(), USER_CREATOR);
/*      */     
/*      */ 
/* 1204 */     transport = authUser(USER_CREATOR);
/* 1205 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/* 1207 */     group = prov.getGroup(Key.DistributionListBy.name, NAME);
/* 1208 */     Assert.assertNull(null);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void subscribeDistributionList() throws Exception {
/* 1213 */     SoapTransport transport = authUser(USER_NOT_OWNER);
/*      */     
/*      */ 
/* 1216 */     SubscribeDistributionListRequest req = new SubscribeDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(DL_NAME), DistributionListSubscribeOp.subscribe);
/*      */     
/*      */ 
/*      */ 
/* 1220 */     SubscribeDistributionListResponse resp = (SubscribeDistributionListResponse)invokeJaxb(transport, req);
/* 1221 */     Assert.assertEquals(DistributionListSubscribeStatus.subscribed, resp.getStatus());
/*      */     
/*      */ 
/* 1224 */     req = new SubscribeDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(DL_NAME), DistributionListSubscribeOp.unsubscribe);
/*      */     
/*      */ 
/*      */ 
/* 1228 */     boolean caughtPermDenied = false;
/*      */     try {
/* 1230 */       resp = (SubscribeDistributionListResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1232 */       String code = e.getCode();
/* 1233 */       if ("service.PERM_DENIED".equals(code)) {
/* 1234 */         caughtPermDenied = true;
/*      */       }
/*      */     }
/* 1237 */     Assert.assertTrue(caughtPermDenied);
/*      */   }
/*      */   
/*      */   @Test
/*      */   public void getAccountDistributionLists() throws Exception {
/* 1242 */     String GROUP_1_NAME = getAddress(genGroupNameLocalPart("1"));
/* 1243 */     String GROUP_1_DISPLAY_NAME = "last";
/* 1244 */     String GROUP_2_NAME = getAddress(genGroupNameLocalPart("2"));
/* 1245 */     String GROUP_2_DISPLAY_NAME = "first";
/* 1246 */     String GROUP_3_NAME = getAddress(genGroupNameLocalPart("3"));
/* 1247 */     String GROUP_3_DISPLAY_NAME = "first";
/* 1248 */     String GROUP_4_NAME = getAddress(genGroupNameLocalPart("4"));
/* 1249 */     String GROUP_4_DISPLAY_NAME = "first";
/*      */     
/* 1251 */     Group group1 = provUtil.createGroup(GROUP_1_NAME, Collections.singletonMap("displayName", GROUP_1_DISPLAY_NAME), true);
/*      */     
/*      */ 
/* 1254 */     Group group2 = provUtil.createGroup(GROUP_2_NAME, Collections.singletonMap("displayName", GROUP_2_DISPLAY_NAME), true);
/*      */     
/*      */ 
/* 1257 */     Group group3 = provUtil.createGroup(GROUP_3_NAME, Collections.singletonMap("displayName", GROUP_3_DISPLAY_NAME), true);
/*      */     
/*      */ 
/* 1260 */     Group group4 = provUtil.createGroup(GROUP_4_NAME, Collections.singletonMap("displayName", GROUP_4_DISPLAY_NAME), true);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1265 */     String ACCT_NAME = getAddress(genAcctNameLocalPart());
/* 1266 */     Account acct = provUtil.createAccount(ACCT_NAME);
/*      */     
/*      */ 
/* 1269 */     prov.addGroupMembers(group1, new String[] { ACCT_NAME });
/* 1270 */     prov.addGroupMembers(group2, new String[] { ACCT_NAME });
/* 1271 */     prov.addGroupMembers(group3, new String[] { ACCT_NAME });
/*      */     
/*      */ 
/* 1274 */     prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group1.getName(), com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, acct.getName(), null, Group.GroupOwner.GROUP_OWNER_RIGHT.getName(), null);
/*      */     
/*      */ 
/* 1277 */     prov.grantRight(TargetType.dl.getCode(), TargetBy.name, group4.getName(), com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeSelector.GranteeBy.name, acct.getName(), null, Group.GroupOwner.GROUP_OWNER_RIGHT.getName(), null);
/*      */     
/*      */ 
/*      */ 
/* 1281 */     SoapTransport transport = authUser(ACCT_NAME);
/* 1282 */     GetAccountDistributionListsRequest req = new GetAccountDistributionListsRequest(Boolean.TRUE, MemberOfSelector.all, Sets.newHashSet(new String[] { "zimbraMailStatus", "zimbraDistributionListSubscriptionPolicy", "zimbraDistributionListUnsubscriptionPolicy" }));
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1287 */     GetAccountDistributionListsResponse resp = (GetAccountDistributionListsResponse)invokeJaxb(transport, req);
/*      */     
/* 1289 */     List<String> result = Lists.newArrayList();
/*      */     
/* 1291 */     List<DLInfo> groups = resp.getDlList();
/* 1292 */     for (DLInfo dlInfo : groups) {
/* 1293 */       String id = dlInfo.getId();
/* 1294 */       String name = dlInfo.getName();
/* 1295 */       String displayName = dlInfo.getDisplayName();
/* 1296 */       Boolean isOwner = dlInfo.isOwner();
/* 1297 */       Boolean isMember = dlInfo.isMember();
/*      */       
/* 1299 */       List<? extends KeyValuePair> attrs = dlInfo.getAttrList();
/* 1300 */       List<String> attrValues = Lists.newArrayList();
/* 1301 */       for (KeyValuePair attr : attrs) {
/* 1302 */         String key = attr.getKey();
/* 1303 */         String value = attr.getValue();
/* 1304 */         attrValues.add(Verify.makeResultStr(new Object[] { key, value }));
/*      */       }
/* 1306 */       Collections.sort(attrValues);
/*      */       
/* 1308 */       result.add(Verify.makeResultStr(new Object[] { id, name, displayName, isOwner, isMember, attrValues }));
/*      */     }
/*      */     
/* 1311 */     List<String> expectedAttrValuesOwner = Lists.newArrayList();
/* 1312 */     expectedAttrValuesOwner.add(Verify.makeResultStr(new Object[] { "zimbraDistributionListSubscriptionPolicy", ZAttrProvisioning.DistributionListSubscriptionPolicy.REJECT.name() }));
/*      */     
/*      */ 
/* 1315 */     expectedAttrValuesOwner.add(Verify.makeResultStr(new Object[] { "zimbraDistributionListUnsubscriptionPolicy", ZAttrProvisioning.DistributionListUnsubscriptionPolicy.REJECT.name() }));
/*      */     
/*      */ 
/* 1318 */     expectedAttrValuesOwner.add(Verify.makeResultStr(new Object[] { "zimbraMailStatus", ZAttrProvisioning.MailStatus.enabled.name() }));
/*      */     
/*      */ 
/*      */ 
/* 1322 */     List<String> expectedAttrValuesNonOwner = Lists.newArrayList();
/* 1323 */     expectedAttrValuesNonOwner.add(Verify.makeResultStr(new Object[] { "zimbraDistributionListSubscriptionPolicy", ZAttrProvisioning.DistributionListSubscriptionPolicy.REJECT.name() }));
/*      */     
/*      */ 
/* 1326 */     expectedAttrValuesNonOwner.add(Verify.makeResultStr(new Object[] { "zimbraDistributionListUnsubscriptionPolicy", ZAttrProvisioning.DistributionListUnsubscriptionPolicy.REJECT.name() }));
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1333 */     Verify.verifyEquals(Lists.newArrayList(new String[] { Verify.makeResultStr(new Object[] { group2.getId(), group2.getName(), group2.getDisplayName(), Boolean.FALSE, Boolean.TRUE, expectedAttrValuesNonOwner }), Verify.makeResultStr(new Object[] { group3.getId(), group3.getName(), group3.getDisplayName(), Boolean.FALSE, Boolean.TRUE, expectedAttrValuesNonOwner }), Verify.makeResultStr(new Object[] { group4.getId(), group4.getName(), group4.getDisplayName(), Boolean.TRUE, Boolean.FALSE, expectedAttrValuesOwner }), Verify.makeResultStr(new Object[] { group1.getId(), group1.getName(), group1.getDisplayName(), Boolean.TRUE, Boolean.TRUE, expectedAttrValuesOwner }) }), result);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1347 */     String GROUP_NEW_NAME = getAddress(genGroupNameLocalPart("new"));
/* 1348 */     prov.renameGroup(group1.getId(), GROUP_NEW_NAME);
/*      */     
/*      */ 
/* 1351 */     result.clear();
/* 1352 */     groups = resp.getDlList();
/* 1353 */     for (DLInfo dlInfo : groups) {
/* 1354 */       String id = dlInfo.getId();
/* 1355 */       String name = dlInfo.getName();
/* 1356 */       String displayName = dlInfo.getDisplayName();
/* 1357 */       Boolean isOwner = dlInfo.isOwner();
/* 1358 */       Boolean isMember = dlInfo.isMember();
/*      */       
/* 1360 */       List<? extends KeyValuePair> attrs = dlInfo.getAttrList();
/* 1361 */       List<String> attrValues = Lists.newArrayList();
/* 1362 */       for (KeyValuePair attr : attrs) {
/* 1363 */         String key = attr.getKey();
/* 1364 */         String value = attr.getValue();
/* 1365 */         attrValues.add(Verify.makeResultStr(new Object[] { key, value }));
/*      */       }
/* 1367 */       Collections.sort(attrValues);
/*      */       
/* 1369 */       result.add(Verify.makeResultStr(new Object[] { id, name, displayName, isOwner, isMember, attrValues }));
/*      */     }
/*      */     
/*      */ 
/* 1373 */     Verify.verifyEquals(Lists.newArrayList(new String[] { Verify.makeResultStr(new Object[] { group2.getId(), group2.getName(), group2.getDisplayName(), Boolean.FALSE, Boolean.TRUE, expectedAttrValuesNonOwner }), Verify.makeResultStr(new Object[] { group3.getId(), group3.getName(), group3.getDisplayName(), Boolean.FALSE, Boolean.TRUE, expectedAttrValuesNonOwner }), Verify.makeResultStr(new Object[] { group4.getId(), group4.getName(), group4.getDisplayName(), Boolean.TRUE, Boolean.FALSE, expectedAttrValuesOwner }), Verify.makeResultStr(new Object[] { group1.getId(), group1.getName(), group1.getDisplayName(), Boolean.TRUE, Boolean.TRUE, expectedAttrValuesOwner }) }), result);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   @Test
/*      */   @QA.Bug(bug={66412})
/*      */   public void noHomeServerZimbraAccount()
/*      */     throws Exception
/*      */   {
/* 1393 */     String groupName = TestUtil.getAddress(genGroupNameLocalPart(), DOMAIN_NAME);
/* 1394 */     Group group = provUtil.createGroup(groupName, true);
/*      */     
/*      */ 
/* 1397 */     Map<String, Object> attrs = Maps.newHashMap();
/* 1398 */     attrs.put("zimbraMailHost", null);
/* 1399 */     prov.modifyAttrs(group, attrs);
/*      */     
/* 1401 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1406 */     com.zimbra.soap.account.message.GetDistributionListRequest getDLreq = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(groupName), Boolean.TRUE);
/*      */     
/* 1408 */     verifyCaughtProxyError(transport, getDLreq);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1414 */     DistributionListActionRequest DLActionReq = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(groupName), new DistributionListAction(DistributionListAction.Operation.addMembers));
/*      */     
/*      */ 
/* 1417 */     verifyCaughtProxyError(transport, DLActionReq);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1422 */     SubscribeDistributionListRequest subsDLReq = new SubscribeDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(groupName), DistributionListSubscribeOp.subscribe);
/*      */     
/*      */ 
/* 1425 */     verifyCaughtProxyError(transport, subsDLReq);
/*      */     
/* 1427 */     provUtil.deleteGroup(group);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */   @Test
/*      */   @QA.Bug(bug={66412})
/*      */   public void noHomeServerZimbraAdmin()
/*      */     throws Exception
/*      */   {
/* 1437 */     String groupName = TestUtil.getAddress(genGroupNameLocalPart(), DOMAIN_NAME);
/* 1438 */     Group group = provUtil.createGroup(groupName, true);
/* 1439 */     String groupId = group.getId();
/*      */     
/*      */ 
/* 1442 */     Map<String, Object> attrs = Maps.newHashMap();
/* 1443 */     attrs.put("zimbraMailHost", null);
/* 1444 */     prov.modifyAttrs(group, attrs);
/*      */     
/* 1446 */     SoapTransport transport = authAdmin(ADMIN);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1453 */     Object req = new com.zimbra.soap.admin.message.GetDistributionListRequest(com.zimbra.soap.admin.type.DistributionListSelector.fromName(groupName));
/*      */     
/* 1455 */     com.zimbra.soap.admin.message.GetDistributionListResponse getDLResp = (com.zimbra.soap.admin.message.GetDistributionListResponse)invokeJaxb(transport, req);
/* 1456 */     com.zimbra.soap.admin.type.DistributionListInfo dlInfo = getDLResp.getDl();
/* 1457 */     Assert.assertEquals(groupId, dlInfo.getId());
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1462 */     req = new ModifyDistributionListRequest(groupId);
/* 1463 */     ModifyDistributionListResponse modifyDLResp = (ModifyDistributionListResponse)invokeJaxb(transport, req);
/* 1464 */     dlInfo = modifyDLResp.getDl();
/* 1465 */     Assert.assertEquals(groupId, dlInfo.getId());
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1470 */     req = new AddDistributionListAliasRequest(groupId, TestUtil.getAddress(genGroupNameLocalPart("alias"), DOMAIN_NAME));
/*      */     
/* 1472 */     AddDistributionListAliasResponse addDLAliasResp = (AddDistributionListAliasResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1477 */     req = new RemoveDistributionListAliasRequest(groupId, TestUtil.getAddress(genGroupNameLocalPart("alias"), DOMAIN_NAME));
/*      */     
/* 1479 */     RemoveDistributionListAliasResponse removeDLAliasResp = (RemoveDistributionListAliasResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1484 */     req = new AddDistributionListMemberRequest(groupId, Collections.singleton(TestUtil.getAddress(genAcctNameLocalPart("member"), DOMAIN_NAME)));
/*      */     
/* 1486 */     AddDistributionListMemberResponse addDLMemberResp = (AddDistributionListMemberResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1491 */     req = new RemoveDistributionListMemberRequest(groupId, Collections.singleton(TestUtil.getAddress(genAcctNameLocalPart("member"), DOMAIN_NAME)));
/*      */     
/* 1493 */     RemoveDistributionListMemberResponse removeDLMemberResp = (RemoveDistributionListMemberResponse)invokeJaxb(transport, req);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1498 */     req = new DeleteDistributionListRequest(groupId);
/* 1499 */     DeleteDistributionListResponse deleteDLResp = (DeleteDistributionListResponse)invokeJaxb(transport, req);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */   @Test
/*      */   public void ownerIsGroup()
/*      */     throws Exception
/*      */   {
/* 1508 */     Group ownedGroup = provUtil.createGroup(genGroupNameLocalPart("owned"), domain, true);
/* 1509 */     Group owningGroup = provUtil.createGroup(genGroupNameLocalPart("owning"), domain, true);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1514 */     Account acctInOwningGroup = provUtil.createAccount("acctInOwningGroup", domain);
/* 1515 */     prov.addGroupMembers(owningGroup, new String[] { acctInOwningGroup.getName() });
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1520 */     prov.grantRight(TargetType.dl.getCode(), TargetBy.name, ownedGroup.getName(), com.zimbra.cs.account.accesscontrol.GranteeType.GT_GROUP.getCode(), GranteeSelector.GranteeBy.name, owningGroup.getName(), null, Group.GroupOwner.GROUP_OWNER_RIGHT.getName(), null);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1527 */     SoapTransport transport = authUser(acctInOwningGroup.getName());
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1533 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.addMembers);
/* 1534 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(ownedGroup.getName()), action);
/*      */     
/*      */ 
/* 1537 */     String MEMBER1 = "member1@test.com";
/* 1538 */     String MEMBER2 = "member2@test.com";
/* 1539 */     action.addMember(MEMBER1);
/* 1540 */     action.addMember(MEMBER2);
/* 1541 */     DistributionListActionResponse resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     
/* 1543 */     Group group = prov.getGroup(Key.DistributionListBy.name, ownedGroup.getName());
/* 1544 */     Set<String> members = group.getAllMembersSet();
/* 1545 */     Assert.assertEquals(2L, members.size());
/* 1546 */     Assert.assertTrue(members.contains(MEMBER1));
/* 1547 */     Assert.assertTrue(members.contains(MEMBER2));
/*      */     
/* 1549 */     provUtil.deleteAccount(acctInOwningGroup);
/* 1550 */     provUtil.deleteGroup(owningGroup);
/* 1551 */     provUtil.deleteGroup(ownedGroup);
/*      */   }
/*      */   
/*      */   @Test
/*      */   @QA.Bug(bug={66234})
/*      */   public void hideInGal() throws Exception
/*      */   {
/* 1558 */     GalTestUtil.enableGalSyncAccount(prov, domain.getName());
/*      */     
/* 1560 */     String GROUP_NAME = getAddress(genGroupNameLocalPart("group"));
/* 1561 */     Multimap<String, String> attrs = ArrayListMultimap.create();
/* 1562 */     attrs.put("zimbraHideInGal", "TRUE");
/*      */     
/*      */ 
/* 1565 */     Account ownerAcct = provUtil.createAccount(genAcctNameLocalPart("owner"), domain);
/* 1566 */     Group group = createGroupAndAddOwner(GROUP_NAME, attrs, ownerAcct.getName());
/*      */     
/*      */ 
/* 1569 */     Account memberAcct1 = provUtil.createAccount(genAcctNameLocalPart("member1"), domain);
/* 1570 */     Account memberAcct2 = provUtil.createAccount(genAcctNameLocalPart("member2"), domain);
/* 1571 */     Account memberAcct3 = provUtil.createAccount(genAcctNameLocalPart("member3"), domain);
/*      */     
/* 1573 */     prov.addGroupMembers(group, new String[] { memberAcct3.getName(), memberAcct2.getName(), memberAcct1.getName() });
/*      */     
/*      */ 
/*      */ 
/* 1577 */     Account nonMemberAcct = provUtil.createAccount(genAcctNameLocalPart("non-member"), domain);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1583 */     SoapTransport transport = authUser(ownerAcct.getName());
/* 1584 */     GetDistributionListMembersRequest req = new GetDistributionListMembersRequest(null, null, group.getName());
/*      */     
/*      */ 
/* 1587 */     GetDistributionListMembersResponse resp = (GetDistributionListMembersResponse)invokeJaxb(transport, req);
/* 1588 */     List<String> members = resp.getDlMembers();
/*      */     
/* 1590 */     Verify.verifyEquals(Lists.newArrayList(new String[] { memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName() }), members);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1595 */     Account memberAcct4 = provUtil.createAccount(genAcctNameLocalPart("member4"), domain);
/* 1596 */     prov.addGroupMembers(group, new String[] { memberAcct4.getName() });
/* 1597 */     resp = (GetDistributionListMembersResponse)invokeJaxb(transport, req);
/* 1598 */     members = resp.getDlMembers();
/* 1599 */     Verify.verifyEquals(Lists.newArrayList(new String[] { memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName(), memberAcct4.getName() }), members);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1606 */     String errorCode = null;
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1611 */     transport = authUser(memberAcct1.getName());
/* 1612 */     errorCode = null;
/*      */     try {
/* 1614 */       invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1616 */       errorCode = e.getCode();
/*      */     }
/* 1618 */     Assert.assertEquals("account.NO_SUCH_DISTRIBUTION_LIST", errorCode);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1623 */     transport = authUser(nonMemberAcct.getName());
/* 1624 */     errorCode = null;
/*      */     try {
/* 1626 */       invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1628 */       errorCode = e.getCode();
/*      */     }
/* 1630 */     Assert.assertEquals("account.NO_SUCH_DISTRIBUTION_LIST", errorCode);
/*      */     
/* 1632 */     GalTestUtil.disableGalSyncAccount(prov, domain.getName());
/*      */     
/* 1634 */     provUtil.deleteAccount(ownerAcct);
/* 1635 */     provUtil.deleteAccount(memberAcct1);
/* 1636 */     provUtil.deleteAccount(memberAcct2);
/* 1637 */     provUtil.deleteAccount(memberAcct3);
/* 1638 */     provUtil.deleteAccount(memberAcct4);
/* 1639 */     provUtil.deleteAccount(nonMemberAcct);
/* 1640 */     provUtil.deleteGroup(group);
/*      */   }
/*      */   
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */   @Test
/*      */   @QA.Bug(bug={72482, 73460})
/*      */   public void getDistributionListMembersWithGSA()
/*      */     throws Exception
/*      */   {
/* 1652 */     GalTestUtil.enableGalSyncAccount(prov, domain.getName(), "galsync1");
/*      */     
/* 1654 */     String GROUP_NAME = getAddress(genGroupNameLocalPart());
/*      */     
/*      */ 
/* 1657 */     Account ownerAcct = provUtil.createAccount(genAcctNameLocalPart("owner"), domain);
/* 1658 */     Group group = createGroupAndAddOwner(GROUP_NAME, ownerAcct.getName());
/*      */     
/*      */ 
/* 1661 */     Account memberAcct1 = provUtil.createAccount(genAcctNameLocalPart("member1"), domain);
/* 1662 */     Account memberAcct2 = provUtil.createAccount(genAcctNameLocalPart("member2"), domain);
/* 1663 */     Account memberAcct3 = provUtil.createAccount(genAcctNameLocalPart("member3"), domain);
/* 1664 */     Account memberAcct4 = provUtil.createAccount(genAcctNameLocalPart("member4"), domain);
/*      */     
/* 1666 */     prov.addGroupMembers(group, new String[] { memberAcct3.getName(), memberAcct2.getName(), memberAcct1.getName() });
/*      */     
/*      */ 
/*      */ 
/* 1670 */     Account nonMemberAcct = provUtil.createAccount(genAcctNameLocalPart("non-member"), domain);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1676 */     SoapTransport transport = authUser(ownerAcct.getName());
/* 1677 */     GetDistributionListMembersRequest req = new GetDistributionListMembersRequest(null, null, group.getName());
/*      */     
/*      */ 
/* 1680 */     GetDistributionListMembersResponse resp = (GetDistributionListMembersResponse)invokeJaxb(transport, req);
/* 1681 */     List<String> members = resp.getDlMembers();
/*      */     
/* 1683 */     Verify.verifyEquals(Lists.newArrayList(new String[] { memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName() }), members);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1691 */     transport = authUser(memberAcct1.getName());
/* 1692 */     resp = (GetDistributionListMembersResponse)invokeJaxb(transport, req);
/* 1693 */     members = resp.getDlMembers();
/*      */     
/* 1695 */     Verify.verifyEquals(Lists.newArrayList(new String[] { memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName() }), members);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1702 */     transport = authUser(nonMemberAcct.getName());
/* 1703 */     String errorCode = null;
/*      */     try {
/* 1705 */       invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) {
/* 1707 */       errorCode = e.getCode();
/*      */     }
/* 1709 */     Assert.assertEquals("account.NO_SUCH_DISTRIBUTION_LIST", errorCode);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1715 */     GalTestUtil.disableGalSyncAccount(prov, domain.getName());
/* 1716 */     GalTestUtil.enableGalSyncAccount(prov, domain.getName(), "galsync2");
/*      */     
/*      */ 
/* 1719 */     transport = authUser(nonMemberAcct.getName());
/* 1720 */     resp = (GetDistributionListMembersResponse)invokeJaxb(transport, req);
/* 1721 */     members = resp.getDlMembers();
/*      */     
/* 1723 */     Verify.verifyEquals(Lists.newArrayList(new String[] { memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName() }), members);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1728 */     prov.addGroupMembers(group, new String[] { memberAcct4.getName() });
/*      */     
/*      */ 
/* 1731 */     transport = authUser(ownerAcct.getName());
/* 1732 */     resp = (GetDistributionListMembersResponse)invokeJaxb(transport, req);
/* 1733 */     members = resp.getDlMembers();
/* 1734 */     Verify.verifyEquals(Lists.newArrayList(new String[] { memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName(), memberAcct4.getName() }), members);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1739 */     transport = authUser(memberAcct1.getName());
/* 1740 */     resp = (GetDistributionListMembersResponse)invokeJaxb(transport, req);
/* 1741 */     members = resp.getDlMembers();
/* 1742 */     Verify.verifyEquals(Lists.newArrayList(new String[] { memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName(), memberAcct4.getName() }), members);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1748 */     transport = authUser(nonMemberAcct.getName());
/* 1749 */     resp = (GetDistributionListMembersResponse)invokeJaxb(transport, req);
/* 1750 */     members = resp.getDlMembers();
/*      */     
/* 1752 */     Verify.verifyEquals(Lists.newArrayList(new String[] { memberAcct1.getName(), memberAcct2.getName(), memberAcct3.getName() }), members);
/*      */     
/*      */ 
/*      */ 
/* 1756 */     GalTestUtil.disableGalSyncAccount(prov, domain.getName());
/*      */     
/* 1758 */     provUtil.deleteAccount(ownerAcct);
/* 1759 */     provUtil.deleteAccount(memberAcct1);
/* 1760 */     provUtil.deleteAccount(memberAcct2);
/* 1761 */     provUtil.deleteAccount(memberAcct3);
/* 1762 */     provUtil.deleteAccount(memberAcct4);
/* 1763 */     provUtil.deleteAccount(nonMemberAcct);
/* 1764 */     provUtil.deleteGroup(group);
/*      */   }
/*      */   
/*      */   @Test
/*      */   @QA.Bug(bug={72791})
/*      */   public void InvalidOwnerEmail() throws Exception {
/* 1770 */     String GROUP_NAME = getAddress(genGroupNameLocalPart());
/*      */     
/* 1772 */     String errorCode = null;
/*      */     try {
/* 1774 */       group = createGroupAndAddOwner(GROUP_NAME, "bogus@bogus.com");
/*      */     } catch (ServiceException e) { Group group;
/* 1776 */       errorCode = e.getCode();
/*      */     }
/* 1778 */     Assert.assertEquals("account.NO_SUCH_ACCOUNT", errorCode);
/*      */   }
/*      */   
/*      */   @Test
/*      */   @QA.Bug(bug={72791})
/*      */   public void distributionListActionSetBadOwners() throws Exception {
/* 1784 */     String GROUP_NAME = getAddress(genGroupNameLocalPart());
/* 1785 */     Group group = createGroupAndAddOwner(GROUP_NAME);
/*      */     
/* 1787 */     Account owner1 = provUtil.createAccount(genAcctNameLocalPart("1"), domain);
/* 1788 */     Account owner2 = provUtil.createAccount(genAcctNameLocalPart("2"), domain);
/* 1789 */     Account owner3 = provUtil.createAccount(genAcctNameLocalPart("3"), domain);
/*      */     
/* 1791 */     SoapTransport transport = authUser(USER_OWNER);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1796 */     DistributionListAction action = new DistributionListAction(DistributionListAction.Operation.setOwners);
/* 1797 */     DistributionListActionRequest req = new DistributionListActionRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), action);
/*      */     
/*      */ 
/* 1800 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, USER_OWNER));
/*      */     
/* 1802 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner1.getName()));
/*      */     
/* 1804 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner2.getName()));
/*      */     
/* 1806 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, owner3.getName()));
/*      */     
/* 1808 */     action.addOwner(new DistributionListGranteeSelector(com.zimbra.soap.type.GranteeType.usr, DistributionListGranteeBy.name, "bogus@bogus.com"));
/*      */     
/*      */ 
/* 1811 */     String errorCode = null;
/*      */     try {
/* 1813 */       resp = (DistributionListActionResponse)invokeJaxb(transport, req);
/*      */     } catch (ServiceException e) { DistributionListActionResponse resp;
/* 1815 */       errorCode = e.getCode();
/*      */     }
/* 1817 */     Assert.assertEquals("account.NO_SUCH_ACCOUNT", errorCode);
/*      */     
/*      */ 
/*      */ 
/*      */ 
/* 1822 */     com.zimbra.soap.account.message.GetDistributionListRequest getDLReq = new com.zimbra.soap.account.message.GetDistributionListRequest(com.zimbra.soap.type.DistributionListSelector.fromName(GROUP_NAME), Boolean.TRUE);
/*      */     
/* 1824 */     com.zimbra.soap.account.message.GetDistributionListResponse getDLResp = (com.zimbra.soap.account.message.GetDistributionListResponse)invokeJaxb(transport, getDLReq);
/* 1825 */     com.zimbra.soap.account.type.DistributionListInfo dlInfo = getDLResp.getDl();
/* 1826 */     List<? extends DistributionListGranteeInfoInterface> owners = dlInfo.getOwners();
/* 1827 */     Set<String> ownerNames = Sets.newHashSet();
/* 1828 */     for (DistributionListGranteeInfoInterface owner : owners) {
/* 1829 */       if (owner.getType() == com.zimbra.soap.type.GranteeType.usr) {
/* 1830 */         ownerNames.add(owner.getName());
/*      */       }
/*      */     }
/* 1833 */     Assert.assertEquals(1L, owners.size());
/* 1834 */     Verify.verifyEquals(Sets.newHashSet(new String[] { USER_OWNER }), ownerNames);
/*      */   }
/*      */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/prov/soap/TestDelegatedDL.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */